<template>
    <div class="helloPage">
        <!-- <span>感谢您访问我的网站！<br></span> -->
        <!-- 个人介绍卡 -->
        <div class="personalBlock" ref="cardRef">
            <img src="@/assets/head.jpg" alt="head" class="personalImg" :class="{ visable: isVisable }" />
            <div class="light" ref="lightRef" v-if="showLight"></div>
            <div class="line"></div>
            <div class="personalInfo">
                <div class="name">NAME: Ji-Chuan</div>
                <div class="job">JOB: FonterDevelopmentEngener</div>
                <div class="email">EMAIL: milikiivana@gmail.com</div>
                <div class="phone">PHONE: 11451419198</div>
                <div class="wechat">WECHAT: 114514</div>
                <div class="qq">QQ: 114514</div>
            </div>
        </div>

        <span ref="text" class="msg" style="-webkit-user-select:none;/*webkit浏览器*/ 
            -moz-user-select:none;/*火狐*/ 
            -ms-user-select:none;/*IE10*/ 
            user-select:none;">
        </span>

        <!-- 图标列表 -->
        <div class="iconlist">
            <img v-for="item in iconList" :key="item.alt" class="icon" :src="item.src" :alt="item.alt" :href="item.href"
                @click="handleClick(item.href)" />
        </div>
    </div>
</template>
<script setup lang="ts">

import { routes } from 'vue-router/auto-routes';
import { ref, onMounted } from 'vue';
import TypeIt from 'typeit';
import { useLight } from './useLight.vue';
// import currentTime from './currentTime.vue';
const { cardRef, lightRef, showLight } = useLight();
const typedContainer = ref(null);
const text = ref();
const time = ref();
let isVisable = false;

const iconList = [{
    src: "/src/assets/bilibili.jpg", //bilibili
    alt: "bilibili",
    href: "https://space.bilibili.com/21224583?spm_id_from=333.337.0.0"
}, {
    src: "/src/assets/weibo.jpg", //weibo
    alt: "weibo",
    href: "https://weibo.com/u/5782320666"
}, {
    src: "/src/assets/pixiv.jpg", //pixiv
    alt: "pixiv",
    href: "https://www.pixiv.net/users/23078012"
}]

onMounted(() => {
    isVisable = true;
    new (TypeIt)(text.value, {
        strings: ["hi!", "欢迎访问我的个人主页！", "祝你玩的开心！", "点击下列图标前往我的社交平台主页："],
        cursorChar: "<span class='cursorChar'>|<span>",//用于光标的字符。HTML也可以
        speed: 100,
        lifeLike: true,// 使打字速度不规则
        cursor: true,//在字符串末尾显示闪烁的光标
        breakLines: true,// 控制是将多个字符串打印在彼此之上，还是删除这些字符串并相互替换
        loop: false,//是否循环
    }).go()
})

function handleClick(href: string) {
    window.open(href, '_blank');
}
</script>
<style scoped>
.helloPage {
    left: auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 70%;
    margin: 0;
    border-radius: 20px;
    background-color: transparent;
    height: 100%;
    flex-direction: column;

    span {
        font-size: 20px;
        color: rgba(255, 255, 255, 1);
        font-weight: bold;
    }

    .time {
        font-size: 20px;
        color: rgba(255, 1);
        font-weight: bold;
        position: absolute;
        top: 5%;
        right: 5%;
    }

}

.personalBlock {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    height: 40%;
    /* 增加高度比例 */
    top: 15%;
    /* 调整垂直位置 */
    left: 20%;
    /* 增加左侧空间 */
    width: 60%;
    /* 增加宽度比例 */
    position: absolute;
    background-color: rgba(59, 59, 61, 0.8);
    border-radius: 24px;
    border: 1px solid rgba(190, 198, 199, 0.8);
    overflow: hidden;
    scrollbar-width: thin;
    /* 火狐浏览器支持 */
    background: linear-gradient(145deg, rgba(59, 59, 61, 0.8), rgba(45, 45, 47, 0.9));
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);

    .personalImg {
        width: 140px;
        height: 140px;
        left: 8%;
        border-radius: 50%;
        margin-right: 15px;
        border: 2px solid rgba(255, 255, 255, 0.1);
        position: absolute;
    }

    .light {
        position: absolute;
        width: 120px;
        height: 120px;
        background: rgba(240, 240, 245, 0.15);
        filter: blur(90px);

    }

    .line {
        width: 1px;
        height: 80%;
        background-color: rgb(190, 198, 199);
        background: linear-gradient(transparent 10%,
                rgba(190, 198, 199, 0.6) 50%,
                transparent 90%);
        margin-top: 10%;
        left: 32%;
        position: absolute;
    }

    &::before {
        content: '';
        position: absolute;
        width: 150%;
        height: 150%;
        background: linear-gradient(45deg,
                rgba(255, 255, 255, 0.1) 0%,
                rgba(255, 255, 255, 0.05) 50%,
                rgba(255, 255, 255, 0.1) 100%);
        transform: rotate(30deg) translate(-20%, -50%);
        animation: lightFlow 6s infinite linear;
        opacity: 0.8;
    }

    &:hover {
        transform: translateY(-8px);
        box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
    }
}

@keyframes lightFlow {
    0% {
        transform: rotate(30deg) translate(-25%, -40%);
    }

    100% {
        transform: rotate(30deg) translate(125%, 60%);;
    }
}

.visable {
    width: 50%;
    height: auto;
}

.personalInfo {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex-wrap: wrap;
    align-items: flex-start;
    line-height: 30px;
    height: auto;
    width: 85%;
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    color: rgb(190, 198, 199);
    left: 38%;
    position: absolute;
    font-family: 'Segoe UI', system-ui;

    div {
        position: relative;
        padding-left: 30px;
        margin: 10px 0;

        &::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            width: 8px;
            height: 8px;
            background: #6DD5FA;
            border-radius: 50%;
            transform: translateY(-50%);
        }
    }

    /* 设置文本不被选中 */
    -webkit-user-select: none;
    /*webkit浏览器*/
    -moz-user-select: none;
    /*火狐*/
    -ms-user-select: none;
    /*IE10*/
    user-select: none;
}

.msg {
    color: rgb(88, 88, 88);
    letter-spacing: 4px;
    font-size: 32px;
    font-weight: lighter;
    position: absolute;
    top: 55%;
    left: 22%;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    color: #E0E0E0;

    &::after {
        content: '';
        display: inline-block;
        width: 2px;
        height: 1.2em;
        background: #6DD5FA;
        margin-left: 4px;
        vertical-align: middle;
        animation: blink 0.8s infinite;
    }
}

.msg :v-deep(.cursorChar) {
    display: inline-block;
    margin-left: 2px;
}

.iconlist {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: row;
    width: auto;
    height: auto;
    position: absolute;
    bottom: 20%;
    left: 22%;
    gap: 25px;

    .icon {
        width: 60px;
        height: 60px;
        margin: 0 10px;
        margin-left: 20px;
        cursor: pointer;
        border-radius: 15px;
        transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        border: 2px solid rgba(255, 255, 255, 0.1);
        background: rgba(255, 255, 255, 0.05);

        &:hover {
            transform: translateY(-3px) scale(1.15);
            box-shadow: 0 4px 15px rgba(109, 213, 250, 0.3);
            border-color: rgba(109, 213, 250, 0.5);
        }

        &:active {
            transform: translateY(1px) scale(0.98);
        }

        @keyframes blink {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0;
            }
        }

        .line {
            background: linear-gradient(transparent, rgba(109, 213, 250, 0.6), transparent);
            width: 2px;
        }
    }
}
</style>